﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Timers;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;

namespace WpfApp1
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        ObservableCollection<Student> StudentCollection = new ObservableCollection<Student>();
        public MainWindow()
        {
            InitializeComponent();

            DispatcherTimer dispatcherTimer = new DispatcherTimer();
            dispatcherTimer.Interval = TimeSpan.FromMilliseconds(1000);
            dispatcherTimer.Tick += DispatcherTimer_Tick;
            dispatcherTimer.Start();
        }
        int a = 0;
        private void DispatcherTimer_Tick(object sender, EventArgs e)
        {
            a++;
            StudentCollection.Insert(0,new Student() { Name = "ys1", Shift = "", Array = a, Score = 12.456d });
            StudentCollection.Insert(0,new Student() { Name = "ys2", Shift = "", Array = a, Score = 12.456d });
            StudentCollection.Insert(0,new Student() { Name = "ys3", Shift = "", Array = a, Score = 12.456d });
            StudentCollection.Insert(0,new Student() { Name = "ys4", Shift = "", Array = a, Score = 12.456d });
        }




        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            //dv.ItemsSource = StudentCollection;
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            dv.ItemsSource = StudentCollection;
        }
    }
}
